﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplicationTest
{
    /// <summary>
    /// url网页重定向示例： http://localhost:5516/Redirect.aspx?https://www.baidu.com
    /// </summary>
    public partial class Redirect : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String redictUrl = getParam();                                  // 获取重定向Url
            if(!redictUrl.Equals("")) Response.Redirect(redictUrl, true);   // 页面重定向跳转
            //Server.Transfer(param, false);    // Server不可跳转其它站点
        }

        /// <summary>
        /// 获取请求参数信息
        /// </summary>
        private String getParam(String LogName = "")
        {
            String Url = Request.Url.ToString();
            String param = "";
            if (Url.Contains("?"))
            {
                param = Url.Substring(Url.IndexOf("?") + 1);                // 获取参数信息

                if (LogName.Equals("")) LogName = this.GetType().Name;
                LogTool log = new LogTool(LogName);                         // 记录至log中
                log.WriteLine(param);
            }
            return param;
        }
    }
}